package rz.stream;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;


public class SysOut {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {

		File file = new File("src");
		System.out.println(file.getAbsolutePath());
		
		String[][] A = new String[5][5];
		try {
			//1.
			//BufferedReader br = new BufferedReader(new FileReader("src/data.txt")); 
			//2.
			BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("src/data1.txt")));
			for (int i=0; i<5; i++) {
				String str = br.readLine();
				A[i] = str.trim().split("\\s{1,}");
			}
			br.close();
			br = null;
			//1.
			//PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("src/data1.txt")));
			//2.
			PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("src/data2.txt"))));
			StringBuffer sb = new StringBuffer();
			for (int j=0; j<5; j++) {
				for (int i=0; i<5; i++) {
					sb.append(A[i][j]).append("\t");
				}
				pw.println(sb.toString());
				sb.delete(0, sb.length());
			}
			pw.close();
			pw = null;
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		new SysOut().echo();
	}
	
	public void echo() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = null;
		while ((s=br.readLine()).length()!=0) {
			System.out.println(s);
		}
		try {
			if (br!=null) {
				br.close();
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}

}
